<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/12/19 0019
 * Time: 下午 2:22
 */

header('content-type:text/html;charset=utf-8');
$filename = 'flock.txt';
$handle = fopen($filename,'a');

if( flock($handle,LOCK_EX) ){  // 如果检测到有锁  发生阻塞等待
    for($i=0;$i<1000000; $i++){
        fwrite($handle,'b');
    }
}